import 'dart:convert';

import 'package:bxultimate/data/request/organization_request.dart';
import 'package:bxultimate/domain/application/organization/OrganizationAnnouncementTemplateCreateDto.dart';
import 'package:get/get.dart';

import 'state.dart';

class OrganizationStatisticsTaskDetailController extends GetxController {
  final OrganizationStatisticsTaskDetailState state = OrganizationStatisticsTaskDetailState();

  var id = Get.arguments;

  @override
  Future<void> onInit() async {
    // TODO: implement onInit
    super.onInit();

    state.taskInfo =
        await OrganizationRequest.getMyReceiveStatisticsTaskInfo(id);

    var data = json.decode(state.taskInfo.taskInfo!);
    state.formItem = data
        .map<OrganizationAnnouncementTemplateCreateDto>(
            (item) => OrganizationAnnouncementTemplateCreateDto.fromJson(item))
        .toList();
  }
}
